package com.ruoyi.web.controller.biz;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.valid.ValidInsertGroup;
import com.ruoyi.system.domain.BsComplain;
import com.ruoyi.system.domain.ro.BsComplainRO;
import com.ruoyi.system.service.IBsComplainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 投诉信息
 *
 * @author ruoyi
 * @date 2023-11-20
 */
@Api(tags = "游客端-投诉")
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/customer/complain")
public class BsComplainYoukeController extends BaseController {

    private final IBsComplainService iBsComplainService;

    @ApiOperation(value = "投诉-列表", tags = {"游客端-投诉"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "分页参数：第几页"),
            @ApiImplicitParam(name = "pageSize", value = "分页参数：每页条数"),
    })
    @GetMapping("/list")
    public Result<TableDataInfo<BsComplain>> list() {
        BsComplainRO ro = BsComplainRO.builder().createById(SecurityUtils.getUserId()).build();
        startPage();
        List<BsComplain> list = iBsComplainService.queryList(ro);
        return Result.success(getDataTable(list));
    }


    @ApiOperation(value = "投诉-新增", tags = {"游客端-投诉"})
    @Log(title = "投诉信息", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping("/add")
    public Result<?> add(@Validated(ValidInsertGroup.class) @RequestBody BsComplainRO bo) {
        return Result.toResult(iBsComplainService.insertByBo(bo));
    }
}
